/*
 * Copyright        : Shendong MCU studio
 * File Description : Main Menu dialog
 * Created          : oliverzhang@shendongmcu.com
 */
#include "gui.h"
#include "bsp_key.h"
static uint8 idata g_con_active = 0;

static const struct gui_control code g_con_list[] =
{
    {CON_TXTBUTTON, 102, 7, "back"},
    {CON_TXTBUTTON, 10, 2, "1.demo 1"},
    {CON_TXTBUTTON, 10, 3, "2.demo 2"},
    {CON_TXTBUTTON, 10, 4, "3.demo 3"},
    {CON_TXTBUTTON, 10, 5, "4.demo 4"},
    {CON_TXTBUTTON, 10, 6, "5.demo 5"},
    {CON_ENDFLAG, 0, 0, NULL}
};

void gui_DlgMainMenuProc(uint8 msg_type, uint8 msg_code)
{
    if(msg_type == WM_TIMER)
    {
    }
    else if(msg_type == WM_KEYPRESSED || msg_type == WM_KEYREPEATED)
    {
        if(msg_code == KEY_UP)
        {
            gui_SearchPrevControl(g_con_list, &g_con_active);
            return;
        }
        else if(msg_code == KEY_DOWN)
        {
            gui_SearchNextControl(g_con_list, &g_con_active);
            return;
        }
        else if(msg_code == KEY_MID)
        {
            switch(g_con_active)
            {
            case 0:
                break;
            case 1:
                gui_Dlg1Open();
                break;
            case 2:
                gui_Dlg2Open();
                break;
            case 3:
                gui_Dlg3Open();
                break;
            case 4:
                gui_Dlg4Open();
                break;
            case 5:
                gui_Dlg5Open();
                break;
            case 6:
                break;
            default:
                break;
            }
            return;
        }
    }
    gui_DlgDefaultProc(msg_type, msg_code);
}

void gui_DlgMainMenuOpen(void)
{
    OLED_Clear();
    gui_DlgSetActive(DLG_MAINMENU);
//    memset(g_con_param_list, 0x00u, sizeof(g_con_param_list));
    OLED_PutStr8x16(32, 0, "Main Menu",NOMALCOLORMODE);
    gui_DrawAllControls(g_con_list, g_con_active);
}



/********************************End of File************************************/